<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>

	
<title>悦章科技机构平台</title>	

	
<!--内容样式-->
<link rel="stylesheet" href="__PUBLIC__/Home/css/style.css" />


	
	
</head>

<body>

	
	<div class="main">
	
	
	<include file="menu" />
		
		
		
		<!--  右侧内容  -->
		<div class="content">
			
			
			<div class= "ct-title">
				<div class="ctt-bt">新增直播课</div>
				<div class="divclear"></div>
			</div>
			
			<div class="xzpt-box">
			
				<div class="xb-title">直播信息</div>
							
				<div class="xb-nr">
					<div class="xbn-zd">直播名称：</div>
					<div class="xbn-r">
						<input type="text" placeholder="请输入直播间标题名称" name="name">
					</div>
					<div class="divclear"></div>
				</div>
				
				<div class="xb-nr">
					<div class="xbn-zd">开播时间：</div>
					<div class="xbn-r">
						<input type="datetime-local" name="live_time">
					</div>
					<div class="divclear"></div>
				</div>
				
				<div class="xb-nr">
					<div class="xbn-zd">直播时长：</div>
					<div class="xbn-r">
						<input type="text" placeholder="请输入直播时长" name="minute"  onchange="check()" id="yb">
						<div class="xbnr-dw">分钟</div>
					</div>
					<div class="divclear"></div>
				</div>
				
				<div class="xb-nr">
					<div class="xbn-zd">直播单价：</div>
					<div class="xbn-r">
						<input type="text" placeholder="请输入直播单价" name="price">
						<div class="xbnr-dw">元/人</div>
					</div>
					<div class="divclear"></div>
				</div>
				<div class="xb-nr">
					<div class="xbn-zd">直播成本价：</div>
					<div class="xbn-r">
						<input type="text" placeholder="直播成本价" id="cb" name="cost_price" disabled="">
						<div class="xbnr-dw">元/人</div>
					</div>
					<div class="divclear"></div>
				</div>
				<div class="xb-nr">
					<div class="xbn-zd">选择老师：</div>
					<div class="xbn-r">
						<select class="type" name="teacher_id">
							
								<option>请选择</option>
							<volist name="teach" id="item">
								<option value="{$item['id']}">{$item['name']}</option>
							</volist>
						</select>
					</div>
					<div class="divclear"></div>
				</div>
				
				<div class="divclear"></div>
				
				<div class="xb-nr" style="width: 100%;">
					<div class="xbn-zd">直播封面：</div>
					<div class="xbn-r" style="width: 320px;height: 200px;padding: 0;">
						<div class="xbnr-img im">
							<img src="__PUBLIC__/Home/images/img_sctp.png" id="cc"/>
						</div>
<!-- 						<div class="xbnr-yc">
							<img src="__PUBLIC__/Home/images/icon_sc.png" />
						</div> -->
							<div style="position: absolute; white-space: nowrap; width: 100%; font-size: 12px; height: 16px; color: #999; text-align: justify;margin-left: 100px">推荐尺寸：320px * 200px</div>
					</div>
					  
					<div class="divclear"></div>
					                      
				</div>
				
				<div class="divclear"></div>
								
				<div class="xb-nr" style="width: 100%;">
					<div class="xbn-zd">直播详情：</div>
					<div class="xbn-r" style="width: calc(100% - 200px);padding: 0;">
																		<textarea style=" margin-left:12px;" id="content" name="desc"></textarea>
							{:hook('documentEditFormContent',array('name'=>'desc'))}
					</div>
					<div class="divclear"></div>
				</div>
				



				<div class="divclear"></div>
				<input type="hidden" name="img" >
				<button class="xb-btn" onClick="document.getElementById('tck-tjsh').style.display='block'">提交审核</button>
				
			</div>
			
			
		</div>
		
		
		
	</div>
	
	
	
	
	<!--提示 弹出框-->
	<div class="tck-demo" id="tck-tjsh">
		
		<div class="tk-box" style="width: 400px;height: 350px;">
			<div class="tkb-title">
				<div class="tkbt-bt">提示</div>
				<div class="tkbt-close" onClick="document.getElementById('tck-tjsh').style.display='none'">
					<img src="__PUBLIC__/Home/images/icon_delete.png" />
				</div>
				<div class="divclear"></div>
			</div>
			<div class="tkb-sqzy">
				<h4>您的直播开课计划创建完毕，已经提交审核<br>平台将尽快为您审核通过</h4>
			</div>
			<div class="tkb-qr" style="margin: 20px auto 0 auto;" onClick="document.getElementById('tck-tjsh').style.display='none'">确定</div>
		</div>
		
	</div>	
	
	
	
	
	
</body>
</html>
<script src="/Public/static/jquery-2.0.3.min.js"></script>
<script src="/Public/static/jquery-1.12.4.min.js"></script>
<script src="/Public/static/jquery.min.js"></script>
<script type="text/javascript">
$("body").on('click','#cc',function(){
    var thisObj = $(this);
    var inputFile = document.createElement("input");
    inputFile.type = "file";
    inputFile.name = "file[]";
    inputFile.multiple = "multiple";
    inputFile.accept = "image/jpeg,image/jpg,image/png";
    inputFile.click();
    $(inputFile).change(function(){
        var files = inputFile.files;
        for(var i=0;i<files.length;i++){
            uploadImg(files[i],thisObj);
        }
    });
});
function uploadImg(file,thisObj){
    var formData = new FormData();
    formData.append('image', file);
    $.ajax({
        url: "{:U('Operate/uploadImg')}",
        type: "post",
        data: formData,
        dataType:"json",
        contentType: false,
        processData: false,
        mimeType: "multipart/form-data",
        success: function (data) {
            if(data.code == 0){
            // 　　console.log(data.info.imgurl);
                var imgid=data.info.imgid;
            	$("input[name='img']").val(imgid);
            	var img=data.info.imgurl;
            	$('.im').html('<img src="'+img+'" id="cc" height="200" width="350"/>');

　　　　　　　}
        },
    });
}

$("body").on('click','.tkb-qr',function(){

	var name=$("input[name='name']").val();
	var live_time=$("input[name='live_time']").val();
	var	minute=$("input[name='minute']").val();
	var	price=$("input[name='price']").val();
	var	cost_price=$("input[name='cost_price']").val();
	if(cost_price>price){
		alert('成本价不能大于单价');return false;
	}
	// var	teacher_id=$("select[name='teacher_id']:selected").val();
	var teacher_id=$('.type option:selected').val();
	var	desc=$('.ke-edit-iframe').contents().find('html body').html();
	// var	desc=$(".ke-content").val();
	var img=$("input[name='img']").val();
    $.ajax({
        url: "{:U('Operate/addLiveCourse')}",
        type: "post",
        data: {name:name,live_time:live_time,minute:minute,price:price,teacher_id:teacher_id,desc:desc,img:img,cost_price:cost_price},
        dataType:"json",
        success: function (data) {
            if(data.result == 1){
            　　alert('新增成功');
    			var url = "{:U('Operate/liveCourse')}";
                location.href=url;

　　　　　　　}else{
				alert('新增失败');
				var url = "{:U('Operate/liveCourse')}";
	            location.href=url;

			}
        },
    });

})

function check(){
	var bl={$bl};
	var myt=document.getElementById("yb");
	if(Number(myt.value)==0 || !(Number(myt.value)%30==0)){
		myt.value="";
	}else{
		// alert(myt.value);return false;
		var cb=myt.value*4;
		var cc=Number(myt.value) + Number(cb);
		var gg=cc*0.00672;
		var hh=gg*bl/100;
		var jj=Number(gg) + Number(hh);
		$('#cb').val(jj);
	}
}
</script>